#include <list.h>
#include <types.h>

void* list_add_behind(struct llist_head **head, struct llist_head *front, struct llist_head *node)
{
    struct llist_head * pnode;
    foreach_llist(pnode, *head){
        if(pnode == front){
            node->next = pnode->next;
            pnode->next = node;
            return pnode;
        }
    }

    return NULL;
}

void list_add(struct llist_head **head, struct llist_head *node)
{
    struct llist_head * phead = *head;

    if(*head == NULL)
        *head == node;
    else{
        while (phead->next != NULL) phead = phead->next;
        phead->next = node;
    }
    node->next = NULL;
}

void list_del(struct llist_head **head, struct llist_head *node)
{
    struct llist_head * phead = *head;

    while (phead->next != node) phead = phead->next;
    phead->next = node->next;

}